#include <stdio.h>
#include <stdlib.h>
#include "pila.h"
#include "abb.h"
#include "bool.h"

struct node {
	Tree tree;
	stack next;
};

stack empty (void) {
	stack pila;

	pila = (stack)calloc(1,sizeof(struct node));
	pila->tree = NULL;
	pila->next = NULL;

	return pila;
}

stack push (stack pila, Tree arbol) {
	stack nodo;

	nodo = (stack)calloc(1,sizeof(struct node));
	nodo->tree = arbol;
	nodo->next = pila->next;
	pila->next = nodo;

	return pila;
}

Tree top (stack pila) {
	return pila->next->tree;
}

stack pop (stack pila) {
	stack q;

	q = pila->next;
	pila->next = q->next;
	free(q);

	return pila;
}

bool is_empty_stack (stack pila) {
	return (pila->next == NULL);
}

